<extend name="Public:base" />
<block name="body">
	<!-- BEGIN PAGE CONTENT-->
	<div class="row">
		<div class="col-md-12">
			<form action="{:U('saveAccess')}" method="post">
				<div class="tabbable tabbable-custom tabbable-full-width">
					<ul class="nav nav-tabs">
						<li class="active">
							<a href="#tab1" data-toggle="tab">访问授权</a>
						</li>
					</ul>
					<div class="tab-content">
						<div class="tab-pane active" id="tab1">
							<volist name="rules" id="v">
								<dl class="checkmod">
									<dt>
										<label class="checkbox">
											<input class="auth_rules rules_all" type="checkbox" value="{$v.id}" name="rules[]" <if condition="in_array( $v['id'], $ruleArr)">checked</if> >{$v.title}
										</label>
									</dt>
									<dd class="bd">
										
										<foreach name="v.child" item="child">
											<div class="rule_check">
												<div>
													<label class="checkbox">
														<input class="auth_rules rules_row" type="checkbox" value="{$child.id}" name="rules[]" <if condition="in_array( $child['id'], $ruleArr)">checked</if>>
														{$child.title}
													</label>
												</div>
												
												<foreach name="child.child" item="chd">
													<span class="child_row">
														<label class="checkbox" style="display:inline-block">
															<input class="auth_rules" type="checkbox" value="{$chd.id}" name="rules[]" <if condition="in_array( $chd['id'], $ruleArr)">checked</if>>
															{$chd.title}
														</label>
													</span>
												</foreach>
											</div>
										</foreach>
									</dd>
								</dl>
							</volist>
						</div>
					</div>
				</div>
                <input type="hidden" name="group_id" value="{:I('get.group_id')}">
				<label  class="control-label"></label>
				<div class="margin-top-10">
					<button type="button" class="btn green ajax-post">确 认</button>&nbsp;&nbsp;
					<a href="javascript:" onclick="javascript:history.back(-1);return false;" class="btn default"> 返 回 </a>
				</div>
			</form>
		</div>
	</div> 
</block>
<block name="script">
	<script type="text/javascript">
	$(function(){
		//导航高亮
		highlight_subnav('{:U('index')}');

		//全选
		$('.rules_all').on('change',function(){
			if( $(this).attr('checked') == 'checked' ) {
				$(this).closest('dl').find('dd').find('span').addClass('checked');
				$(this).closest('dl').find('dd').find('input').prop('checked', 'checked');
			}else{
				$(this).closest('dl').find('dd').find('span').removeClass('checked');
				$(this).closest('dl').find('dd').find('input').prop('checked', '');
			}
		});

		$('.rules_row').on('change',function() {
			if( $(this).attr('checked') == 'checked' ) {
				$(this).closest('.rule_check').find('.child_row').find('span').addClass('checked');
				$(this).closest('.rule_check').find('.child_row').find('input').prop('checked', 'checked');
			}else{
				$(this).closest('.rule_check').find('.child_row').find('span').removeClass('checked');
				$(this).closest('.rule_check').find('.child_row').find('input').prop('checked', '');
			}
			
		})
	});
	</script>
</block>